# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=nosqlattack
pkgver=98.a5b0329
pkgrel=3
pkgdesc='Python tool to automate exploit MongoDB server IP on Internet anddisclose the database data by MongoDB default configuration weaknesses and injection attacks.'
groups=('blackarch' 'blackarch-automation' 'blackarch-scanner')
arch=('any')
url='https://github.com/youngyangyang04/NoSQLAttack'
license=('GPL3')
depends=('python2' 'python2-httplib2' 'python2-pymongo' 'python2-requests'
         'python2-ipcalc' 'python2-shodan' 'mongodb')
makedepends=('git' 'python2-setuptools')
source=("$pkgname::git+https://github.com/youngyangyang04/NoSQLAttack.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE.md"

  rm *.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 main.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

